package com.modules.groups.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.common.response.ResponseVO;
import com.common.utils.Query;
import com.common.utils.R;
import com.modules.groups.entity.Groups;
import com.modules.groups.mapper.GroupsMapper;
import com.modules.groups.service.IGroupsService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("groupsService")
public class GroupsServiceImpl extends ServiceImpl<GroupsMapper, Groups> implements IGroupsService {

    @Override
    public R getPageList(Map<String, Object> params) {
        Integer createBy = Integer.parseInt((String) params.get("createBy"));
        IPage<Groups> page = new Query<Groups>().getPage(params);
        page = this.page(page, new QueryWrapper<Groups>().lambda()
                .eq(createBy != null, Groups::getCreateBy, createBy)
                .orderByDesc(Groups::getCreateTime));
        return R.ok().put("data",page);
    }
}
